<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="js/jquery.js"></script>
  <script>
    $(function(){
      $('#get1').click(function(){
        $.ajax({
          url:'http://127.0.0.1:3001/getnewslist',
          type: 'get',
          success:function(res){
            console.log(res)
          }
        })
      })
      $('#get2').click(function(){
        $.ajax({
          url:'http://127.0.0.1:3001/getnewsdetail',
          type: 'get',
          data: {
            newsid: 7
          },
          success:function(res){
            console.log(res)
          }
        })
      })
      $('#post').click(function(){
        $.ajax({
          url:'http://127.0.0.1:3001/addnews',
          type: 'post',
          data: {
            title: '头条新闻',
            content: 'xxx又出轨了'
          },
          success:function(res){
            console.log(res)
          }
        })
      })
      $('#put').click(function(){
        $.ajax({
          url:'http://127.0.0.1:3001/modify/3',
          type: 'put',
          success:function(res){
            console.log(res)
          }
        })
      })
      $('#delete').click(function(){
        $.ajax({
          url:'http://127.0.0.1:3001/delete/3',
          type: 'delete',
          success:function(res){
            console.log(res)
          }
        })
      })
    })
  </script>
</head>
<body>
  <button id="get1">get请求,获取新闻列表</button> <br>
  <button id="get2">get请求,获取某条新闻详情</button> <br>
  <button id="post">post请求,增加一条新闻数据</button> <br>
  <button id="put">put请求,修改某一条新闻数据</button> <br>
  <button id="delete">delete请求,删除某一条新闻</button> <br>
  <!-- 体会一下不同请求方式在 用途功能\url\传递数据  中的差别
  -->
</body>
</html>